﻿using Microsoft.AspNet.Identity.EntityFramework;
using Smalt.DomainModels.JoinModels;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Smalt.DomainModels.Models;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace Smalt.Data
{
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("DefaultConnection")
        {
        }

        public DbSet<Team> Teams { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<Community> Communities { get; set; }

        // Join Models
        public DbSet<ApplicationUserCommunity> UserCommunity { get; set; }
        public DbSet<ApplicationUserTeam> UserTeam { get; set; }
        public DbSet<ApplicationUserProject> UserProject { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
        }
    }
}
